package com.staginfo.segs.ui.adapter;


import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.staginfo.segs.R;
import com.staginfo.segs.ui.fragment.HomeFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by robert.luozizhao on 2017/9/13 0013.
 */

public class WarningPagerAdapter extends FragmentPagerAdapter {

    private Context mContext;
    private HomeFragment mHomeFragment;
    private List<Fragment> mFragmentList = new ArrayList<>();

    private String[] mTitles = {"个人警告","全部警告"};
    private int[] mNormalImages = {R.mipmap.ic_launcher_round, R.drawable.setting_icon};


    public WarningPagerAdapter(FragmentManager fm, Context context, HomeFragment HomeFragment) {
        super(fm);
        mContext = context;
        mHomeFragment = HomeFragment;
    }

    public void setFragmentList(List<Fragment> fragmentList) {
        mFragmentList = fragmentList;
    }


    @Override
    public Fragment getItem(int position) {
        return mFragmentList.get(position);
    }

    @Override
    public int getCount() {
        return mFragmentList.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mTitles[position];
    }



    public View getTabView(int position){
        View view = LayoutInflater.from(mContext).inflate(R.layout.icon_layout, null);
        TextView textView = (TextView) view.findViewById(R.id.title_tv);
        ImageView img = (ImageView) view.findViewById(R.id.img);
        img.setImageResource(mNormalImages[position]);
        textView.setText(mTitles[position]);
        return view;
    }


}
